/**
 * ContentBlacklist模型 - 用于存储内容黑名单
 */
const { DataTypes } = require('sequelize');

module.exports = (sequelize) => {
  const ContentBlacklist = sequelize.define('ContentBlacklist', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    content: {
      type: DataTypes.STRING(255),
      allowNull: false,
      comment: '被拦截的内容（关键词或正则表达式）'
    },
    type: {
      type: DataTypes.ENUM('keyword', 'regex'),
      allowNull: false,
      defaultValue: 'keyword',
      comment: '内容类型：关键词或正则表达式'
    },
    action: {
      type: DataTypes.ENUM('block', 'flag'),
      allowNull: false,
      defaultValue: 'flag',
      comment: '动作：完全拦截或标记为敏感'
    },
    reason: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: '拦截原因'
    },
    status: {
      type: DataTypes.ENUM('active', 'inactive'),
      allowNull: false,
      defaultValue: 'active',
      comment: '拦截状态'
    },
    createdBy: {
      type: DataTypes.STRING(50),
      allowNull: true,
      comment: '创建者'
    }
  }, {
    tableName: 'content_blacklist',
    timestamps: true,
    indexes: [
      {
        unique: true,
        fields: ['content', 'type']
      }
    ]
  });

  return ContentBlacklist;
}; 